home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Demos / Extend 3.0 Demo / Extend Demo / Extend Demo.rsrc / HELP_260_ ModL Message Handlers < prev    next >
Encoding:
Text File  |  1994-07-14  |  4.0 KB  |  66 lines

  1. Following the declarations and comments in a ModL script are lines of programming code that are grouped into sections. Each section is either a message handler or a function or procedure. The procedures, functions, and message handlers are just definitions: they need to be called in order to be executed. Extend's built-in functions and procedures are listed in the ModL Functions help topic. Also see the ModL Language Overview concerning declaring user-defined functions and procedures.
  2.  
  3. Message handlers interpret messages that come from the simulation or from you. Extend runs the message handler whenever one of the messages is passed to the block. Message handlers begin with a line “on xxx”. For example, a message handler you see in every block begins “on Simulate” and the message handler script starts and ends with curly braces ({ and }) as follows:
  4.  
  5. on MessageName
  6. {
  7. local variable declarations
  8. zero or more statements;
  9. }
  10.  
  11. The MessageName must be a dialog message name, a connector name, or a system message name as listed below. System messages are sent to blocks by Extend when you build models, run a simulation, or execute ModL code containing function calls that explicitly send messages to other blocks. Dialog messages are the names of buttons and are sent to the block when you click the button.
  12.  
  13. You exit from a message handler with a RETURN statement or an ABORT statement.
  14.  
  15. The System and Dialog message names are:
  16.  
  17. • AbortSim
  18. This message is sent to all blocks only when an Extend simulation run is aborted prematurely by an error or by the user stopping the simulation. After the AbortSim is sent, EndSim is sent to all blocks.
  19.  
  20. • BlockReceive0...BlockReceive3
  21. To allow a block to receive a user defined message from another block using the SendMsgToBlock function.
  22.  
  23. • CheckData
  24. Used to check the compatibility and validity of the dialog input data.  ABORT if the data is not valid. This message handler allows testing connectors for a connection to another block.  If connected, the connector’s variable value is TRUE; if not connected, FALSE. There are several system functions for determining connectivity with other blocks.
  25.  
  26. • ConnectorName
  27. When the named connector on the block receives a connector message from another block using the connector message functions.
  28.  
  29. • CreateBlock
  30. Allows the model to initialize its data with any numbers, etc. Is called when the block is added to a model.
  31.  
  32. • DialogClose
  33. Allows the script to "Clean up" just before the dialog box is closed.
  34.  
  35. • DialogOpen
  36. Allows the user to set up items, such as static text labels, before dialog box is shown.
  37.  
  38. • EndSim
  39. Clean up and dispose of any memory, etc.
  40.  
  41. • HBlockOpen
  42. Allows the user to set up items, such as animation, before the submodel is opened.
  43.  
  44. • InitSim
  45. Initialize your data. Allows the block to use the final DeltaTime calculated to generate arrays, or other initializations. Is called just before the simulation starts.
  46.  
  47. • OpenModel
  48. This message is sent to all blocks when an Extend model is opened. This allows blocks to initialize variables showing that the model was just opened.
  49.  
  50. • ResumeSim
  51. This allows the script to respond to changes before continuing the simulation after the user has either:
  52. 1) clicked dialog buttons during the simulation, or
  53. 2) edited a parameter and chosen Resume from the Run menu or clicked the Resume button in the simulation status bar.
  54.  
  55. • Simulate
  56. Used to get a new simulation output connector value from the present input connector values.
  57.  
  58. • StepSize
  59. Used to calculate a DeltaTime. Is called after all the CheckData messages.  In the message handler, set DeltaTime to the value you would like to have.  The minimum of the calculated DeltaTime of all blocks is used for the simulation.
  60.  
  61. • YourButton
  62. If you have created a button, radio button, or check box named YourButton, this message handler is activated when the button is clicked.
  63.  
  64. • YourParameter
  65. If the user unselects a parameter or editable text item, this message handler is sent to the block so that the script can optionally check the entered value.
  66.